import React from "react";

export default function TestHoc(UserCom) {
  return class extends React.Component {
    state = {
      x: '',
      y: '',
    };

    componentDidMount() {
      window.addEventListener('scroll', this.handleScroll);
    }

    componentWillUnmount() {
      window.removeEventListener('scroll', this.handleScroll);
    }

    handleScroll = () => {
      this.setState({
        x: window.scrollX,
        y: window.scrollY,
      });
    };

    render() {
      return (
        <div>
          <h2>TestHoc</h2>
          <UserCom {...this.props} x={this.state.x} y={this.state.y} />
        </div>
      );
    }
  };
}
